function [xp, yp] = make_patch(x, y, ye)
% function to make data for patch plot from x and y arrays (where y is standard deviation of x)
% t is the time base
% check the inputs.
xp=[]; yp=[];
if(prod(size(x)) > length(x))
   fprintf(2, 'make_patch: X array needs to be unidimensional\n');
   return;
end;
if(prod(size(y)) > length(y))
   fprintf(2, 'make_patch: Y array needs to be unidimensional\n');
   return;
end;
if(prod(size(ye)) > length(ye))
   fprintf(2, 'make_patch: YE array needs to be unidimensional\n');
   return;
end;
% size:
if(length(x) ~= length(y) | length(y) ~= length(ye))
   fprintf(2, 'make_patch: All input arrays must be the same length\n');
   return;
end;

% dimensionality - make all into columns
if(size(x, 1) ~= 1)
   x = x';
end;
if(size(y, 1) ~= 1)
   y = y';
end;
if(size(ye, 1) ~= 1)
   ye = ye';
end;


vp=y+ye;
vn=y-ye;
yp = [vp vn(end:-1:1)];
xp = [x x(end:-1:1)];
lx = find(isnan(yp)); % just in case
for i = lx
   if(i == 1)
      yp(1)=yp(2);
   elseif (i == length(yp))
      yp(i) = yp(i-1);
   else
      yp(i) = yp(i-1);
   end;
end;
